#ifndef B74318AD_1D20_4831_AD62_044B207E22AF
#define B74318AD_1D20_4831_AD62_044B207E22AF

#include "log.hpp"
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <string>
#include <cstring>

using namespace std;

const string path = "/home/yg"; 
const int proj_id = 0x8532;
Log log;

key_t Getkey()
{
	key_t key = ftok(path.c_str(),proj_id);
	if(key == -1){
		log(Fatal,"ftok error:%s",strerror(errno));
		exit(1);
	}
	return key;
}

int Getmsgmid(int flag)
{
	key_t key = Getkey();
	int msgmid = msgget(key,flag);
	if(msgmid == -1){
		log(Fatal,"msgget error:%s",strerror(errno));
		exit(2);
	}
}

int Createmsgmid()
{
	return Getmsgmid(0666|IPC_CREAT|IPC_EXCL);
}

int Getmid()
{
	return Getmsgmid(IPC_CREAT);
}

#endif /* B74318AD_1D20_4831_AD62_044B207E22AF */
